package com.xinqi.modules.course.demonstrate.service.impl;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.xinqi.modules.course.course.mapper.CourseMapper;
import com.xinqi.modules.course.demonstrate.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * 示范课程-课程
 *
 * @author dzy
 */
@Service("demoCourseService")
@RequiredArgsConstructor
public class DemoCourseServiceImpl implements DemoCourseService {

    /**
     * 课程
     */
    private final CourseMapper courseMapper;

    private final IdentifierGenerator identifierGenerator;

    private final DemoClassService demoClassService;

    private final DemoHomeworkService demoHomeworkService;

    private final DemoExamService demoExamService;

    private final DemoNoticeService demoNoticeService;

    private final DemoDiscussService demoDiscussService;

    private final DemoResourceService demoResourceService;

    private final DemoSyncService demoSyncService;

    /**
     * 同步课程信息SQL
     *
     * @param userId 同步用户Id
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void initCourseSql(Long userId) {
        StringBuilder sqlSb = new StringBuilder();
        // 生成课程
        Long courseId = identifierGenerator.nextId(null).longValue();
        String courseSql = "INSERT INTO co_course(`id`, `create_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `delete_time`, `school_id`" +
            ", `user_id`, `course_name`, `introduce`, `course_color_bg`, `course_color_cover`, `course_image_cover_app`, `course_image_cover_pc`" +
            ", `status`, `is_top`, `is_del`, `is_name_editable`, `name_edit_count`, `archive`, `file_url`, `link`, `extend`) " +
            "VALUES (" + courseId + ", " + userId + ", '2023-05-24 09:38:28', " + userId + ", '2023-05-31 09:32:22', 0, 0, NULL, " + userId +
            ", '熟悉新奇', '熟悉课堂', 0, NULL, NULL, NULL, 'NORMAL', NULL, 0, 0, 3, 'NORMAL', NULL, '[]', NULL);";
        sqlSb.append(courseSql);
        // 执行SQL语句
        courseMapper.insertAllSql(sqlSb.toString());

        // 生成班级
        Long classId = demoClassService.initClassSql(userId, courseId);

        // 生成小组
        Long oldClassId = 1661184856792928257L;
        demoSyncService.initGroup(courseId, classId, oldClassId);

        // 生成章节信息
        Map<String, String> chapterMap = this.initChapterSql(userId, courseId, classId);

        // 生成公告信息
        String[] noticeIds = new String[]{"1663469811618603009", "1663706828562554882"};
        Map<String, String> noticeIdsMap = new HashMap<>();
        for (int i = 0; i < noticeIds.length; i++) {
            Long id = identifierGenerator.nextId(null).longValue();
            noticeIdsMap.put(noticeIds[i], id.toString());
        }
        demoNoticeService.initNoticeSql(userId, classId, noticeIdsMap, chapterMap);

        // 生成讨论信息
        String[] discussIds = new String[]{"1662785767952781314", "1663424373238587393", "1663429659873566721"};
        Map<String, String> discussIdsMap = new HashMap<>();
        for (int i = 0; i < discussIds.length; i++) {
            Long id = identifierGenerator.nextId(null).longValue();
            discussIdsMap.put(discussIds[i], id.toString());
        }
        demoDiscussService.initDiscussSql(userId, classId, discussIdsMap, chapterMap);

        // 生成作业信息
        String[] homeworkIds = new String[]{"1663103282536943618", "1663161671128354817"
            , "1663374180027785217", "1663704572006031361", "1663751131439620098"};
        Map<String, String> homeworkIdsMap = new HashMap<>();
        for (int i = 0; i < homeworkIds.length; i++) {
            Long id = identifierGenerator.nextId(null).longValue();
            homeworkIdsMap.put(homeworkIds[i], id.toString());
        }
        demoHomeworkService.initHomeworkSql(userId, classId, homeworkIdsMap, chapterMap);

        // 生成测评信息
        String[] examIds = new String[]{"493814434741887213", "493814764384821510", "493834006190624813"};
        Map<String, String> examIdsMap = new HashMap<>();
        for (int i = 0; i < examIds.length; i++) {
            Long id = identifierGenerator.nextId(null).longValue();
            examIdsMap.put(examIds[i], id.toString());
        }
        demoExamService.initExamSql(userId, courseId, classId, examIdsMap, chapterMap);

        // 更新资料库
        String[] oldIds = new String[]{"1663459329386012674", "1663459721134006274", "1663461179422203905", "1663505937125400578"};
        Map<String, String> resourceMap = new HashMap<>();
        for (int i = 0; i < oldIds.length; i++) {
            Long id = identifierGenerator.nextId(null).longValue();
            resourceMap.put(oldIds[i], id.toString());
        }
        demoResourceService.initResourceSql(userId, classId, resourceMap, chapterMap);

        // 同步汇总表
        Map<String, String> contentMap = new HashMap<>();
        contentMap.putAll(noticeIdsMap);
        contentMap.putAll(discussIdsMap);
        contentMap.putAll(homeworkIdsMap);
        contentMap.putAll(examIdsMap);
        contentMap.putAll(resourceMap);
        this.initContent(userId, courseId, classId, contentMap, chapterMap);
    }

    /**
     * 章节管理Sql
     */
    private Map<String, String> initChapterSql(Long userId, Long courseId, Long classId) {
        StringBuilder sql = new StringBuilder();
        String[] oldIds = new String[]{"1661193644765777922", "1661193644769972225", "1661193644769972226", "1661193644774166530", "1661193644774166531", "1661193644778360833"
            , "1661193644778360834", "1661193644782555138", "1661193644782555139", "1661193644786749441", "1661193644786749442", "1661193644790943746"};
        Map<String, String> map = new HashMap<>();
        for (int i = 0; i < oldIds.length; i++) {
            Long id = identifierGenerator.nextId(null).longValue();
            map.put(oldIds[i], id.toString());
        }
        String chapterSql = "INSERT INTO `co_course_chapter` (`id`, `create_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `delete_time`, `class_id`, `course_id`, `pid`, `name`, `sort`) " +
            "VALUES (" + map.get("1661193644765777922") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-25 10:12:14', 0, 0, 1661184856792928257, 1661184856092479489, 0, '第一章  ', 0)," +
            "(" + map.get("1661193644769972225") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644765777922, '第1小节', 1)," +
            "(" + map.get("1661193644769972226") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644765777922, '第2小节', 2)," +
            "(" + map.get("1661193644774166530") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644765777922, '第3小节', 3)," +
            "(" + map.get("1661193644774166531") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 0, '第二章', 1)," +
            "(" + map.get("1661193644778360833") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644774166531, '第1小节', 1)," +
            "(" + map.get("1661193644778360834") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644774166531, '第2小节', 2)," +
            "(" + map.get("1661193644782555138") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644774166531, '第3小节', 3)," +
            "(" + map.get("1661193644782555139") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 0, '第三章', 2)," +
            "(" + map.get("1661193644786749441") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644782555139, '第1小节', 1)," +
            "(" + map.get("1661193644786749442") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644782555139, '第2小节', 2)," +
            "(" + map.get("1661193644790943746") + ", 1645325062446964737, '2023-05-24 10:13:23', 1645325062446964737, '2023-05-24 10:13:23', 0, 0, 1661184856792928257, 1661184856092479489, 1661193644782555139, '第3小节', 3);";
        Set<String> keyList = map.keySet();
        for (String item : keyList) {
            String value = map.get(item);
            chapterSql = chapterSql.replaceAll(item, value);
        }
        chapterSql = chapterSql.replaceAll("1661184856092479489", courseId.toString());
        chapterSql = chapterSql.replaceAll("1661184856792928257", classId.toString());
        sql.append(chapterSql);

        // 执行SQL
        courseMapper.insertAllSql(sql.toString());
        return map;
    }

    private void initContent(Long userId, Long courseId, Long classId, Map<String, String> contentMap, Map<String, String> chapterMap) {
        String contentSql = "INSERT INTO co_course_content(`id`, `create_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `delete_time`, `user_id`, `school_id`, `course_id`, `class_id`, `content_id`, `repeated_day`, `task_type`, `type`, `title`, `content`, `chapter_id`, `release_time`, `end_time`, `start_time`, `status`, `complet_number`, `learning_number`, `learned_number`, `approved_number`, `paid_number`, `partake_number`, `comment_number`, `student_number`, `sort`, `is_read`) " +
            "VALUES (" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-28 19:39:55', 1, '2023-05-28 21:41:49', 0, 0, " + userId + ", NULL, NULL, 1661184856792928257, 1662785767952781314, 1, NULL, 5, '关于保护环境的讨论', '生态环境是立身之本，请同学们谈谈如何保护环境。', 0, '2023-05-28 19:39:55', '2023-05-28 21:42:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-30 13:57:30', 1, '2023-05-31 11:47:55', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663424373238587393, 1, NULL, 5, '《水的运动》—章后问题研究讨论 （必须回复）', '通过前面的学习，我们知道因为洋流、纬度、海陆等原因造成不同的气候，同时造成不同的地理环境。南极洲面积为1400万平方千米，95%以上的地方常年被冰雪覆盖，形成了巨大而厚实的冰盖。冰盖平均厚度达2450 米，冰雪总量约2700万立方千米，占全球冰雪总量的 90%以上，占全世界可用淡水的 72%。有人估算，这里的淡水资源可供全球使用7 500年。因此，南极洲是人类最大的淡水资源库，而且很少受到污染，水质极好。那么，我们能否利用南极的冰山解决沙特阿拉伯的缺水问题呢?请同学们通过讨论的方式探究这一课题，可通过图片或文字的形式将搜集到的资料和观点发表在评论区。', 1661193644786749441, '2023-05-30 20:12:23', '2023-06-20 00:00:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-30 14:18:31', 1, '2023-06-14 22:13:37', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663429659873566721, 1, NULL, 5, '评述植物生长调节剂在生产中的应用', '查看下列资料，在评论区回复以下问题。\\n1.你还知道哪些植物生长调节剂在农产品和园艺生产上应用的例子?\\n2.在生产过程中施用植物生长调节剂要注意哪些事项?\\n3.我国禁止销售、使用未经国家有关部门批准的植物生长调节剂。这是为什么?', 1661193644765777922, '2023-05-30 20:12:18', '2023-06-20 00:00:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            //"(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-30 15:44:12', " + userId + ", '2023-06-14 22:17:47', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663451224401043457, 1, NULL, 1, '《第二节  运动的描述》互动课件', NULL, 0, '2023-05-30 20:13:15', '2023-06-02 00:00:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-30 16:16:24', " + userId + ", '2023-05-30 20:13:45', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663459329386012674, 1, NULL, 2, '熟悉新奇资料——关于课程的设置', NULL, 0, '2023-05-30 20:13:45', NULL, NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-30 16:17:58', " + userId + ", '2023-05-30 20:13:43', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663459721134006274, 1, NULL, 2, '熟悉新奇资料——如何发布作业', NULL, 0, '2023-05-30 20:13:43', NULL, NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-30 16:23:45', " + userId + ", '2023-05-30 20:13:40', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663461179422203905, 1, NULL, 2, '熟悉新奇资料——如何编辑互动试题', NULL, 0, '2023-05-30 20:13:40', NULL, NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-30 19:21:37', " + userId + ", '2023-05-31 11:21:33', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663505937125400578, 1, NULL, 6, '认识锈斑豹猫—互动视频', NULL, 1661193644769972226, '2023-05-30 20:13:30', '2023-05-31 11:30:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-30 16:58:04', 1, '2023-05-31 11:47:39', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663469811618603009, 1, NULL, 8, '第二次数学月考范围', '各位同学：\\n即将到来的数学月考将涉及以下章节的内容，请务必认真复习：\\n\\n一、 高中数学基础知识：\\n\\n （一）整式与分式\\n1、一次函数与二次函数\\n2、 指数与对数\\n3、 三角函数与解三角形\\n4、 平面几何与立体几何\\n\\n二、 高中数学选修课内容：\\n\\n（一）概率与统计\\n1、 数学分析\\n2、微积分。\\n\\n请同学们认真复习以上章节的相关知识点，做好准备，以便在月考中取得好成绩。\\n\\n祝愿各位同学考试成功！\\n\\n谢谢。', 0, '2023-05-30 20:13:55', '2023-06-20 00:00:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-31 08:39:53', 1, '2023-05-31 11:47:33', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663706828562554882, 1, NULL, 8, '关于端午节放假的通知', '尊敬的家长和同学们：\\n端午节即将到来，按照国家法定节假日规定放假三天，具体安排如下：\\n 1. 放假时间：2023年6月22日至6月24日。6月25 日按照规定正常上课。\\n 2. 放假期间，学校各项活动停止，校园内禁止进出人员，保障同学们的安全。\\n 3. 节日期间，同学们要注意安全，避免参加危险的活动，如游泳、攀岩等。 \\n 4. 放假后，同学们要按时返校，遵守学校的规定，做到文明礼仪，积极参加学校组织的各项活动。 \\n最后，祝愿同学们在端午节期间，健康快乐，度过一个愉快的假期！ \\n特此通知。 \\n学校：新奇中学 \\n日期：2023年6月3日 \\n请点击“确认”回复此公告', 0, '2023-05-31 08:39:53', '2023-06-20 09:00:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-31 11:35:55', " + userId + ", '2023-05-31 11:42:00', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663751131439620098, 1, 1, 3, '第一节  生物的特征作业（助教发布）', '什么是生物?也许你会说，能生长的东西就是生物。岩洞里的钟乳石也能从小长大，它也是生物吗?或许你还想到，能自主运动的东西就是生物树木花草不能移动位置，为什么说它们也是生物?请同学们以word的形式提交作业，描述你认为生物是什么？生物的特征是什么？', 0, '2023-05-31 11:36:21', '2023-05-31 11:45:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-29 16:41:36', " + userId + ", '2023-05-31 11:23:16', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663103282536943618, 1, 2, 3, '综合性学习作业（小组作业）—人无信不立', '“信”，即诚信，是中华民族的传统美德之一，也是社会主义核心价值观之一。在古人眼中，“信”是立身之本、交友之道、经商之魂、为政之要；在现代社会，诚信是公民的第二张身份证。无论古今，诚信应该成为个人必有的精神品质。先哲们在思考“信”这一道德规范时，留下了很多精彩论述。\n各小组分别搜集有关“信”的名言警句、成语典故、名人逸事及其他经典论述，理解“信”的传统内涵。汇总并整理本组搜集的资料，将资料按类别划分“交友之信”“经商之信”“国家之信”等。最后每个小组采取一种类别，每个人以word文档形式6月30日20：00前提交一份资料。小组长在“评论”中说明每组查找的资料类别，为什么选取该类别？', 1661193644769972225, '2023-05-30 20:11:52', '2023-05-31 11:30:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-05-29 20:33:37', " + userId + ", '2023-05-30 20:11:33', 0, 0, NULL, NULL, NULL, 1661184856792928257, 1663161671128354817, 1, 1, 3, '打卡作业—每日阅读感想', '读经典作品，更有利于文化积累，让自己的思想与大师们联网接轨。鲁迅的作品在当代中国，就像莎士比亚的作品在英国，普希金的作品在俄罗斯，已成为民族语言和文化的象征。读鲁迅，会比读当下流行的那些“文化快餐”书籍有更多的收获。请每位同学选择一本鲁迅的书籍进行课后阅读，在一个月内完成，并每天提交一篇不少于300字的读书感想。', 1661193644778360833, '2023-05-30 20:11:32', '2023-05-31 22:00:00', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-09-17 16:02:16', " + userId + ", '2023-09-17 16:03:02', 0, 0, " + userId + ", NULL, NULL, 1661184856792928257, 493814434741887213, 1, NULL, 4, '单元考试（限时答题）', '本次成绩计入学年个人成绩统计，请同学们认真作答，发现作弊将废除成绩。', 490448584953570175, '2023-09-17 16:03:02', '2023-09-21 00:00:00', '2023-09-17 16:04:44', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-09-17 16:03:34', " + userId + ", '2023-09-17 16:03:48', 0, 0, " + userId + ", NULL, NULL, 1661184856792928257, 493814764384821510, 1, NULL, 4, '期中考试', '本次成绩计入学年个人成绩统计，请同学们认真作答，发现作弊将废除成绩。', 490448584953570182, '2023-09-17 16:03:48', '2023-09-29 00:00:00', '2023-09-17 16:04:38', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)," +
            "(" + identifierGenerator.nextId(classId) + ", " + userId + ", '2023-09-17 17:20:02', " + userId + ", '2023-09-17 17:20:02', 0, 0, " + userId + ", NULL, NULL, 1661184856792928257, 493834006190624813, 1, NULL, 4, '课后测评', '考试规则： \\n1.本次考试为线上考试，请提前准备参考设备。 \\n2.多选题，答错答少不得分。', 490448584953570175, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);";
        // 更新课程ID
        contentSql = contentSql.replaceAll("1661184856092479489", courseId.toString());
        // 更新班级ID
        contentSql = contentSql.replaceAll("1661184856792928257", classId.toString());
        // 更新内容ID
        Set<String> contentList = contentMap.keySet();
        for (String item : contentList) {
            String value = contentMap.get(item);
            contentSql = contentSql.replaceAll(item, value);
        }
        // 更新章节
        Set<String> keyList = chapterMap.keySet();
        for (String item : keyList) {
            String value = chapterMap.get(item);
            contentSql = contentSql.replaceAll(item, value);
        }

        // 评论SQL
        String commonSql = "INSERT INTO cmn_comment(`id`, `create_by`, `create_time`, `update_by`, `update_time`, `class_id`, `type`, `content_id`, `user_id`, `to_user_id`, `is_read`, `pid`, `super_pid`, `title`, `images`) " +
            "VALUES (" + identifierGenerator.nextId(classId) + ", 1661185385489694721, '2023-05-25 15:07:52', 1661185385489694721, '2023-05-25 15:07:52', 1661184856792928257, 5, 1661619896433676289, " + userId + ", 0, 1, 0, 0, '1. 减少能源消耗和碳排放：使用低能耗的电器和灯具，少开空调和暖气，选择步行、骑车或公共交通等低碳出行方式。\\n2. 垃圾分类和减量：将垃圾分类投放，尽量减少使用一次性餐具和塑料袋等一次性消费品的使用。\\n3. 节约水资源：用水勤俭，修复漏水，减少用水浪费。\\n\\n', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1650458704827445249, '2023-05-25 15:12:34', 1650458704827445249, '2023-05-25 15:12:34', 1661184856792928257, 5, 1661619896433676289, 1650458704827445249, 0, 1, 0, 0, '1. 保护生态环境：保护野生动物和植物，不乱扔垃圾，不随意采摘和破坏自然资源。\\n2. 推广可持续发展：选择环保产品，支持环保企业，鼓励低碳生活方式。\\n3. 科技创新：各行各业都应积极探索应用科技手段，提高资源利用效率和减少污染排放。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1656548738307391489, '2023-05-28 19:51:10', 1656548738307391489, '2023-05-28 19:51:10', 1661184856792928257, 5, 1662785767952781314, 1656548738307391489, 0, 1, 0, 0, '1. 保护生态环境：保护野生动物和植物，不乱扔垃圾，不随意采摘和破坏自然资源。 2. 推广可持续发展：选择环保产品，支持环保企业，鼓励低碳生活方式。 3. 科技创新：各行各业都应积极探索应用科技手段，提高资源利用效率和减少污染排放。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1656548738307391489, '2023-05-28 19:54:20', 1656548738307391489, '2023-05-28 19:54:20', 1661184856792928257, 5, 1662769663977099266, 1656548738307391489, 0, 1, 0, 0, '科技的发展的好处有是提高了生产力和效率，产品质量提高；提供了便利和舒适的生活方式，例如互联网、智能手机、智能家居等。科技的发展的坏处有环境污染和资源浪费；信息泄露和网络安全问题。为了平衡科技的利弊，我们应该加强科技伦理和社会责任意识的教育和培养，使人们更加重视科技的影响和后果。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1650458704827445249, '2023-05-28 20:02:11', 1650458704827445249, '2023-05-28 20:02:11', 1661184856792928257, 5, 1662785767952781314, 1650458704827445249, 0, 1, 0, 0, '1. 减少能源消耗和碳排放：使用低能耗的电器和灯具，少开空调和暖气，选择步行、骑车或公共交通等低碳出行方式。 2. 垃圾分类和减量：将垃圾分类投放，尽量减少使用一次性餐具和塑料袋等一次性消费品的使用。 3. 节约水资源：用水勤俭，修复漏水，减少用水浪费。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1650458704827445249, '2023-05-28 20:03:58', 1650458704827445249, '2023-05-28 20:03:58', 1661184856792928257, 5, 1662769663977099266, 1650458704827445249, 0, 1, 0, 0, '科技的好处有促进了医疗保健的进步，使得许多疾病得到了更好的治疗和预防。科技的发展也带来了一些坏处，例如社交隔离和孤独感，例如人们更倾向于使用社交媒体而不是面对面交流。面对科技的利弊，我们应该支持和鼓励创新和发明，为社会发展提供更多的选择和可能性。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1661185385489694721, '2023-05-28 20:50:13', 1661185385489694721, '2023-05-28 20:50:13', 1661184856792928257, 5, 1662785767952781314, 1661185385489694721, 0, 1, 0, 0, '加强法律法规和监管：政府和社会应加强环境保护的法律法规，加强监管和执法力度，形成全社会共同参与环保的氛围。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1661185385489694721, '2023-05-28 20:52:03', 1661185385489694721, '2023-05-28 20:52:03', 1661184856792928257, 5, 1662769663977099266, 1661185385489694721, 0, 1, 0, 0, '科技提高了教育水平，使得知识的获取更加容易和便捷；但是也造成科技依赖性和成瘾性，例如对游戏、社交媒体和互联网的过度依赖和成瘾。我们要提高人们的科技素养和技能，使人们更好地掌握和利用科技。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1653986821394567169, '2023-05-28 21:06:47', 1653986821394567169, '2023-05-28 21:06:47', 1661184856792928257, 5, 1662785767952781314, 1653986821394567169, 0, 1, 0, 0, '从我做起，从身边的小事做起。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1654693737893134337, '2023-05-28 21:09:41', 1654693737893134337, '2023-05-28 21:09:41', 1661184856792928257, 5, 1662785767952781314, 1654693737893134337, 0, 1, 0, 0, '植树造林，积极参与植树造林活动，增加绿色植被覆盖面积，促进生态平衡。关注环保政策，积极关注环保政策，支持环保组织，参与环保活动，共同保护环境。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1654693737893134337, '2023-05-28 21:11:23', 1654693737893134337, '2023-05-28 21:11:23', 1661184856792928257, 5, 1662769663977099266, 1654693737893134337, 0, 1, 0, 0, '科技增加了娱乐和文化的多样性，例如游戏、电影、音乐等。但也造成技术失业和不平等，例如机器人和自动化技术的普及导致许多工人失业，我们要利用科技的好的部分比如创新和发明，为社会进步提高帮助。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1655650372358701057, '2023-05-30 11:54:28', 1655650372358701057, '2023-05-30 11:54:28', 1661184856792928257, 6, 1662796585557725186, 1655650372358701057, 0, 1, 0, 0, '11', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1656548738307391489, '2023-05-30 20:35:40', 1656548738307391489, '2023-05-30 20:35:40', 1661184856792928257, 3, 1663103282536943618, 1656548738307391489, 0, 1, 0, 0, '我们小组选取的是“国家之信”，我们认为国家之信是指国家在国内和国际上的信誉和声誉。它是一个国家维护自身利益和影响力的重要因素。国家之信是国家内部稳定和发展的重要任务，需要通过提高国家形象、加强对外交往、保障国内法制和公平正义等多种手段来实现。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1661185385489694721, '2023-05-30 20:37:57', 1661185385489694721, '2023-05-30 20:37:57', 1661184856792928257, 3, 1663103282536943618, 1661185385489694721, 0, 1, 0, 0, '我们小组选取的是“交友之信”。交友之信的重要性在于它可以表现一个人的诚实、可信和诚信。信件是一种非常正式的交流方式，通过写信表达自己的想法和感受，可以让人们更加深入地了解对方，建立更加稳固的友谊关系。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1650458704827445249, '2023-05-30 20:39:15', 1650458704827445249, '2023-05-30 20:39:15', 1661184856792928257, 3, 1663103282536943618, 1650458704827445249, 0, 1, 0, 0, '我们小组选取的是“经商之信”。经商之信是商业活动中最重要的一环，它涉及到商业伦理、商业道德和商业信誉等方面。在商业活动中，经商之信可以帮助企业建立良好的声誉和信誉，提高客户对企业的信任度和忠诚度。同时，经商之信也可以促进商业交流和合作，建立长期稳定的商业关系。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1654693737893134337, '2023-05-30 20:59:22', 1654693737893134337, '2023-05-30 20:59:22', 1661184856792928257, 5, 1663424373238587393, 1654693737893134337, 0, 1, 0, 0, '从理论上讲，我们可以利用南极的冰山解决沙特阿拉伯的缺水问题。南极洲是全球最大的冰山贮藏地，拥有世界上约90%的淡水储备。如果能够将南极洲的冰山运输到沙特阿拉伯，那么就可以解决沙特阿拉伯的缺水问题。然而，这个方案实施起来存在巨大的技术和经济挑战。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1654693737893134337, '2023-05-30 20:59:28', 1654693737893134337, '2023-05-30 20:59:28', 1661184856792928257, 5, 1663424373238587393, 1654693737893134337, 0, 1, 0, 0, NULL, 'https://xinqiclass.oss-cn-hangzhou.aliyuncs.com/2023-05-30/1685451564401378-b81ca1d836c18a85165a6be4d54843820b036b7b45d4-z7YbzM_fw658.webp.jpg')," +
            "(" + identifierGenerator.nextId(classId) + ", 1654693737893134337, '2023-05-30 21:03:57', 1654693737893134337, '2023-05-30 21:03:57', 1661184856792928257, 5, 1663429659873566721, 1654693737893134337, 0, 1, 0, 0, '1. 壮苗素：可促进作物根系发育、增强植物抗逆能力，如水稻、小麦、玉米等。\\n\\n2. 生长素：可促进植物生长，增加果实数量和质量，如番茄、黄瓜、西瓜等。\\n\\n3. 翻译素：可促进植物花期开放，提高花粉活力，增加果实产量和质量，如葡萄、苹果、梨等。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1650458704827445249, '2023-05-30 21:10:41', 1650458704827445249, '2023-05-30 21:10:41', 1661184856792928257, 5, 1663429659873566721, 1650458704827445249, 0, 1, 0, 0, '1. 选择合适的植物生长调节剂，根据作物、生长阶段、环境条件等因素进行选择。\\n\\n2. 严格按照说明书或专业人员的指导进行施用，遵守使用剂量、浓度、频率等方面的要求。\\n\\n3. 选择适当的施用方法，如喷雾、浸泡、涂抹等，根据作物的生长状况和环境条件选择最适合的方法。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1650458704827445249, '2023-05-30 21:13:08', 1650458704827445249, '2023-05-30 21:13:08', 1661184856792928257, 5, 1663424373238587393, 1650458704827445249, 0, 1, 0, 0, '虽然理论上可以利用南极的冰山解决沙特阿拉伯的缺水问题，但实际上这个方案存在很多难以克服的困难，需要进一步的技术和经济探索。南极洲的冰山体积巨大，需要大量的能源和物资才能将其运输到沙特阿拉伯。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1653986821394567169, '2023-05-30 21:23:21', 1653986821394567169, '2023-05-30 21:23:21', 1661184856792928257, 8, 1663468259461881858, 1653986821394567169, 0, 1, 0, 0, '祝老师和同学们端午节快乐', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1653986821394567169, '2023-05-30 21:24:26', 1653986821394567169, '2023-05-30 21:24:26', 1661184856792928257, 5, 1663424373238587393, 1653986821394567169, 0, 1, 0, 0, '这个方案需要建立一个庞大的基础设施网络，包括冰山采集、运输、存储和分配等环节，需要大量的人力物力，成本高昂。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1653986821394567169, '2023-05-30 21:26:10', 1653986821394567169, '2023-05-30 21:26:10', 1661184856792928257, 5, 1663424373238587393, 1653986821394567169, 0, 1, 0, 0, NULL, 'https://xinqiclass.oss-cn-hangzhou.aliyuncs.com/2023-05-30/16854531608135-t018a197c04d7894e2f.jpg')," +
            "(" + identifierGenerator.nextId(classId) + ", 1653986821394567169, '2023-05-30 21:26:53', 1653986821394567169, '2023-05-30 21:26:53', 1661184856792928257, 5, 1663429659873566721, 1653986821394567169, 0, 1, 0, 0, '有炭疽孢素：可增加作物的耐旱性、抗逆能力及产量，如大豆、玉米、棉花等。赤霉素：可促进作物生长，增加产量和品质，如水稻、小麦、玉米等。乙烯利：可延缓植物老化，提高果实品质，如番茄、苹果、梨等。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1654693737893134337, '2023-05-31 08:42:46', 1654693737893134337, '2023-05-31 08:42:46', 1661184856792928257, 8, 1663706828562554882, 1654693737893134337, 0, 1, 0, 0, '祝老师和同学们端午节快乐', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1656548738307391489, '2023-05-31 08:45:20', 1656548738307391489, '2023-05-31 08:45:20', 1661184856792928257, 8, 1663706828562554882, 1656548738307391489, 0, 1, 0, 0, '祝大家端午节快乐，身体安康', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1656548738307391489, '2023-05-31 08:49:44', 1656548738307391489, '2023-05-31 08:49:44', 1661184856792928257, 5, 1663429659873566721, 1656548738307391489, 0, 1, 0, 0, '禁止销售、使用未经国家有关部门批准的植物生长调节剂是为了保护农作物的质量和安全，防止不合格的植物生长调节剂对人类健康和环境造成危害。未经批准的植物生长调节剂可能存在一定的毒性和残留问题，对人体健康和环境造成潜在风险。因此，为了确保农产品的品质和安全，我国制定了相关法律法规，禁止销', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1661185385489694721, '2023-05-31 08:58:57', 1661185385489694721, '2023-05-31 08:58:57', 1661184856792928257, 5, 1663429659873566721, 1661185385489694721, 0, 1, 0, 0, '在生产过程中施用植物生长调节剂要注意\\n1、在施用前要对植物进行检查，确保植物处于健康生长状态，避免施用对植物的伤害。\\n2、施用过程中要注意安全，穿戴好防护装备，避免接触皮肤、眼睛等敏感部位。\\n3、施用后要及时清洗施用工具和周围环境，避免残留物对环境和人体健康的影响。', NULL)," +
            "(" + identifierGenerator.nextId(classId) + ", 1661185385489694721, '2023-05-31 09:04:26', 1661185385489694721, '2023-05-31 09:04:26', 1661184856792928257, 8, 1663706828562554882, 1661185385489694721, 0, 1, 0, 0, NULL, 'https://xinqiclass.oss-cn-hangzhou.aliyuncs.com/2023-05-31/1685495058961919-微信截图_20230531090407.png');";
        // 更新内容ID
        for (String item : contentList) {
            String value = contentMap.get(item);
            commonSql = commonSql.replaceAll(item, value);
        }
        // 更新课程ID
        commonSql = commonSql.replaceAll("1661184856092479489", courseId.toString());
        // 更新班级ID
        commonSql = commonSql.replaceAll("1661184856792928257", classId.toString());
        // 执行SQL语句
        courseMapper.insertAllSql(contentSql);
        courseMapper.insertAllSql(commonSql);
    }

}
